/*
 * map.h
 *
 *  Created on: 15 nov. 2010
 *      Author: Nicolas Aucouturier, Laurent Reveillere
 */

#ifndef MAP_H_
#define MAP_H_

#include <stdlib.h>
#include <stdio.h>
#include "SDL.h"
#include "SDL_image.h"

typedef enum {
	CELL_EMPTY=0,
	CELL_GOAL,  // 1
	CELL_SCENERY, // 2
	CELL_PLAYER, // 3
	CELL_CASE,   // 4
	CELL_BONUS, // 5
	CELL_MONSTER, // 6
	CELL_BOMB, // 7
	CELL_KEY, // 8
	CELL_DOOR, // 9
	//CELL_CLOSED_DOOR // 10
   CELL_BOMBERWOMAN
} t_cell_type;

typedef enum {
	BONUS_EMPTY=0,
	BONUS_BOMB_RANGE_INC=1,
	BONUS_BOMB_RANGE_DEC,
	BONUS_BOMB_NB_INC,
	BONUS_BOMB_NB_DEC,
	BONUS_LIFE,
	BONUS_MONSTER
} t_bonus_type;

typedef enum {
	SCENERY_STONE=1, SCENERY_TREE
} t_scenery_type;

//Les trucs rajoutés commencent ici
typedef enum {
	OPENED_MAP_0=0, OPENED_MAP_1,OPENED_MAP_2,OPENED_MAP_3,OPENED_MAP_4,OPENED_MAP_5
} t_opened_type;

typedef enum {
	CLOSED_MAP_0=8, CLOSED_MAP_1,CLOSED_MAP_2,CLOSED_MAP_3,CLOSED_MAP_4,CLOSED_MAP_5
} t_closed_type;

typedef enum {
	CELL_OPENED_MAP_0= CELL_DOOR | (OPENED_MAP_0 << 4),
	CELL_OPENED_MAP_1= CELL_DOOR | (OPENED_MAP_1 << 4),
	CELL_OPENED_MAP_2= CELL_DOOR | (OPENED_MAP_2 << 4),
	CELL_OPENED_MAP_3= CELL_DOOR | (OPENED_MAP_3 << 4),
	CELL_OPENED_MAP_4= CELL_DOOR | (OPENED_MAP_4 << 4),
	CELL_OPENED_MAP_5= CELL_DOOR | (OPENED_MAP_5 << 4),
	CELL_CLOSED_MAP_0= CELL_DOOR | (CLOSED_MAP_0 << 4),
	CELL_CLOSED_MAP_1= CELL_DOOR | (CLOSED_MAP_1 << 4),
	CELL_CLOSED_MAP_2= CELL_DOOR | (CLOSED_MAP_2 << 4),
	CELL_CLOSED_MAP_3= CELL_DOOR | (CLOSED_MAP_3 << 4),
	CELL_CLOSED_MAP_4= CELL_DOOR | (CLOSED_MAP_4 << 4),
	CELL_CLOSED_MAP_5= CELL_DOOR | (CLOSED_MAP_5 << 4),

} t_door_type;

//et se terminent ici


typedef enum {
	CELL_STONE = CELL_SCENERY | (SCENERY_STONE << 4),
	CELL_TREE = CELL_SCENERY | (SCENERY_TREE << 4),
	CELL_CASE_BOMBINC = CELL_CASE | (BONUS_BOMB_NB_INC << 4),
    CELL_CASE_BOMBDEC = CELL_CASE | (BONUS_BOMB_NB_DEC << 4),
    CELL_CASE_RANGEINC = CELL_CASE | (BONUS_BOMB_RANGE_INC << 4),
    CELL_CASE_RANGEDEC = CELL_CASE | (BONUS_BOMB_RANGE_DEC << 4),
    CELL_CASE_LIFE = CELL_CASE | (BONUS_LIFE << 4),
    CELL_CASE_MONSTER = CELL_CASE | (BONUS_MONSTER << 4),
    CELL_CASE_EMPTY = CELL_CASE | (BONUS_EMPTY << 4),
	CELL_BONUS_BOMBINC = CELL_BONUS | (BONUS_BOMB_NB_INC << 4),
    CELL_BONUS_BOMBDEC = CELL_BONUS | (BONUS_BOMB_NB_DEC << 4),
    CELL_BONUS_RANGEINC = CELL_BONUS | (BONUS_BOMB_RANGE_INC << 4),
    CELL_BONUS_RANGEDEC = CELL_BONUS | (BONUS_BOMB_RANGE_DEC << 4),
    CELL_BONUS_LIFE = CELL_BONUS | (BONUS_LIFE << 4),
    CELL_BONUS_MONSTER = CELL_BONUS | (BONUS_MONSTER << 4)

} t_compose_type;

typedef struct s_map* t_map;

// Create a new empty map
extern t_map map_new(int width, int height);
extern void map_free(t_map map);


// Return the height and width of a map
extern int map_get_width(t_map map);
extern int map_get_height(t_map map);


// Return the type of a cell
extern t_cell_type map_get_cell_type(t_map map, int x, int y);

extern t_cell_type map_get_cell_type2(t_map map, int x, int y);

// Set the type of a cell
extern void  map_set_cell_type(t_map map, int x, int y, t_cell_type type);

// Test if (x,y) is within the map
extern int map_is_inside(t_map map, int x, int y);

//Get the current map of the player
extern t_map map_get_current(int num_level,int num_map);

//Management of the door; state (open or close) and number of the level behind
extern t_cell_type map_get_door_state(t_map map, int x, int y);
extern t_cell_type map_get_door_numb(t_map map, int x, int y);

// Display the map on the screen
extern void map_display(t_map map, SDL_Surface *screen);
extern void display_door(t_map map, SDL_Surface* screen, SDL_Rect* place,t_cell_type type);
extern void display_bonus(t_map map, SDL_Surface* screen, SDL_Rect* place, t_cell_type type);
extern void display_scenery(t_map map, SDL_Surface* screen, SDL_Rect* place,t_cell_type type);

//Remove the
extern t_map map_get_bomb_removed(t_map map);


extern t_map map_set_bonus(t_map map);

#endif /* MAP_H_ */
